class AlbumsController < ApplicationController
  skip_before_action :authenticate_request, only: [:show, :index]

  def create
    document = JSONAPI.parse(params.to_unsafe_h)
    @album = Album.new(name: document.data.attributes.name, publishtime: document.data.attributes.publishtime)
    @album.save!
    obj_return(@album, status: 201)
  end

  def index
    obj_return(Album.all, status: 200)
  end

  def show
    @album = Album.find(params[:id])
    obj_return(@album, status: 200)
  end

  def destroy
    @album = Album.find(params[:id])
    @album.destroy
    err_return(:ok,status: 200)
  end

  def update
  end
end
